MacOS X Developer Preview Release Notes Copyright © 1999-2000 by Apple Computer, Inc. All Rights Reserved.
This file contains release notes for the AppleScript.
AppleScript 1.5 in Mac OS X is functionally identical to AppleScript 1.4 in Mac OS 9. It is a Component Manager component accessible through the OSA APIs in OSA.h with additional AppleScript-specific APIs in AppleScript.h and ASDebugging.h. It makes extensive use of the Apple Event manager whose APIs are in AppleEvents.h, AEDataModel.h, and associated headers.
AppleScript 1.5 consists of the following files:
OSA and AppleScript components | /System/Library/Components/AppleScript.qtx /System/Library/Components/OSAApplet.qtx |
Script Editor | /System/Applications/Script Editor.app |
Standard Additions | /System/Library/ScriptingAdditions/StandardAdditions.osax |
Command-line OSA tool | /usr/bin/osascript |
Because of underlying differences between Mac OS 9 and Mac OS X, there will be some characteristic differences in the behavior of AppleScript in Mac OS X. In particular, AppleScript on Mac OS X does not share any data between different applications, which leads to some differences in how terminology and handlers are updated.
Mac OS X will not support Mac OS 9 scripting additions (OSAXen). Because only applications can safely link to CarbonLib on Mac OS 9, scripting additions on 9 must link to InterfaceLib, which is not supported on Mac OS X. Scripting additions for Mac OS X must be shared libraries using Carbon. See Tech Note 1164 for details on how to build scripting additions as shared libraries, then Carbonize normally. Scripting additions built as packages will be supported, but the API is not yet final.
osascript
is a terminal tool that executes scripts and prints the
result to stdout
.
osascript
[-l
language] [file...]
File parameters are either text files or compiled script files. Raw text
is assumed to be code in the default scripting language, which is normally
AppleScript. You can override this by specifying a scripting component name
using the -l
flag. Multiple files are compiled into a single
context, which is then executed. If no file parameters are given,
osascript
reads from stdin
.
Examples:
# echo "2+3" | /usr/bin/osascript
5
# echo 'tell application "Desktop.app" to get window 1' > test
# /usr/bin/osascript test
window "Applications" of application "Desktop.app"
osascript
will not work correctly if it is found using your
PATH
. You must specify the complete path to it (i.e.
/usr/bin/osascript
) to run it.
osascript
has trouble with Mac-style (i.e., CR-delimited) text
files and comments. In particular, "--" comments will comment to the end of the file.
To work around this, convert the file to Unix-style (i.e. LF-delimited.)
In general, AppleScript or Standard Additions functions that rely on features
not implemented in Mac OS X will fail. This includes mounting AFP volumes (mount volume),
interprocess communication between machines (choose application, machine "foo"),
and Find by Content (summarize). There are some known problems with the Aqua appearance
in the display dialog
and choose from list
scripting additions.
Applets now work.
Package-based applications are fully supported
AppleScript looks for the application name as it appears in the file system, not as it appears in the Dock. For example, in order to script TextEdit, you must say:
tell application "TextEdit.app"
as opposed to:
tell application "TextEdit"
Scripting additions are not loaded into an application until that application compiles
or executes a script. This means that most applications will not understand scripting
addition-based commands like display dialog
. For example, normally you could
say this:
tell application "Desktop.app"
display dialog "Hello, world!"
end tell
This would cause the dialog "Hello, world!" to appear in the Finder. In DP4, it will fail. You must target the display dialog call at the script itself by doing either of the following:
tell application "Desktop.app"
tell me to display dialog "Hello, world!"
end tell
tell application "Desktop.app"
-- Desktop-specific actions here.
end tell
display dialog "Hello, world!"
Implicit application launching, either to execute a script or to get a dictionary, does not work correctly. The application will launch, but AppleScript will try to send it events before it is ready to receive them and fail. The workaround is to launch applications manually before scripting them.
Script Editor has a number of cosmetic bugs and is not fully Aqua-compliant.
The "Open Dictionary..." command may show unscriptable applications and not show scriptable ones. You can work around this by dropping the application icon on Script Editor to open the dictionary.
Finder scripts running in Classic that used to work in DP3 may not work in DP4, because the Classic Finder no longer exists, and the native Finder (now called Desktop) is not fully scriptable. This should be fixed by Mac OS X GM.